package com.light.gulimall.order.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class OrderConfirmVO {
    // 收货地址，ums_member_receive_address 表
    private List<MemberAddressVo> addresses;
    // 购物清单，根据购物车页面传递过来的 skuIds 查询
    private List<CartItem> orderItems;
    // 可用积分，ums_member 表中的 integration 字段
    private Integer bounds;

    //订单总额
    private BigDecimal total;

    //应付总额
    private BigDecimal payPrice;

    // 订单令牌，防止重复提交
    private String orderToken;

    private Integer count;

    private Map<Long,Boolean> hasStock;

    public Integer getCount() {
        this.count = getTotleCount();
        return count;
    }

    public Integer getTotleCount(){
        int count = 0;
        for (CartItem orderItem : orderItems) {
            count += orderItem.getCount();
        }
        return count;
    }
}